package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Person p = new Person("张麒",18);
        System.out.println(p);

        Class cls = Class.forName("reflect.Person");
        Constructor c = cls.getConstructor(String.class,int.class);
        Object obj = c.newInstance("张麒",18);
        System.out.println( obj);

        Constructor c1 = cls.getConstructor(String.class);
        Object obj1 = c1.newInstance("张麒");
        System.out.println( obj1);
    }
}
